package be.jhd.repository;

import org.apache.commons.lang.StringUtils;

import be.jhd.utils.ArtifactNameResolver;

public abstract class Artifact {

	public static final String SNAPSHOT = "-SNAPSHOT";
	
	private final String group;
	private final String artifact;
	private final String version;
	private final String classifier;
	private final String packaging;

	private final boolean snapshot;
	
	public Artifact(String group, String artifact, String version, String classifier, String packaging, boolean snapshot) {
		this.group = group;
		this.artifact = artifact;
		this.version = version;
		this.classifier = classifier;
		this.packaging = packaging;
		this.snapshot = snapshot;
	}

	public Artifact(String group, String artifact, String version) {
		this(group, artifact, version, "", "", false);
	}

	public String getGroup() {
		return group;
	}
	
	public String getArtifact() {
		return artifact;
	}
	
	public String getVersion() {
		return version;
	}
	
	public String getClassifier() {
		return classifier;
	}
	
	public String getPackaging() {
		return packaging;
	}
	
	public boolean isSnapshot(){
		return snapshot;
	}
	
	public boolean isClassified(){
		return !StringUtils.isEmpty(classifier);
	}
	
	@Override
	public String toString() {
		return ArtifactNameResolver.resolve(this);
	}
	
}
